package com.evenmo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import com.evenmo.pojo.Student;

public interface StudentMapper {
	


	@Select("select * from tb_student where clazz_id=#{clazzId,jdbcType=INTEGER}")
@Results(id = "studentResultMap", value = { @Result(id = true, column = "id", property = "id"),
		@Result(column = "name", property = "name"), @Result(column = "age", property = "age"),
		@Result(column = "sex", property = "sex"), @Result(column = "data_flag", property = "dataFlag"),
		@Result(column = "clazz_id", property = "clazzId")})
	public List<Student> queryStudentsByClazzId(@Param("clazzId") Integer clazzId);
	
	
	@Select("select * from tb_student where id=#{id,jdbcType=INTEGER}")
	@Results(id = "studentResultMap2", value = { @Result(id = true, column = "id", property = "id"),
			@Result(column = "name", property = "name"), @Result(column = "age", property = "age"),
			@Result(column = "sex", property = "sex"), @Result(column = "data_flag", property = "dataFlag"),
			@Result(column = "clazz_id", property = "clazzId"),
	@Result(column="clazz_id",property="clazz",one=@One(fetchType=FetchType.EAGER,select="com.evenmo.mapper.ClazzMapper.queryByClazzId"))		
	})
	public Student queryByStudentId(@Param("id") Integer id);
}
